package com.controller.yxy;
import com.service.yxyService.GetDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.util.Map;

/**
 * 账单
 */
@Controller
@RequestMapping("/YXYpage/")
public class BillController {
    @Autowired
    private HttpSession session;
    @Resource
    private GetDataService  getDataService;

    /**5
     *账单
     * @param
     * @return
     */
    @RequestMapping(value = "bianhuachaxu",method = RequestMethod.POST)
    @ResponseBody
    public Object bianhuachaxu(String setter){
        return getDataService.bianhuachaxu(setter);
    }

    /**5
     *账单
     * @param
     * @return
     */
    @RequestMapping(value = "bianhuachaxu1",method = RequestMethod.POST)
    @ResponseBody
    public Object bianhuachaxu1(String setter,String aid){
        return getDataService.bianhuachaxu1(setter,aid);
    }

    /**
     * 判断是否是住户
     * @return
     */
    @RequestMapping(value = "iszhuhuzhangdan",method = RequestMethod.GET)
    @ResponseBody
    public Object iszhuhuzhangdan(){
        Map<String,Object> map = (Map<String,Object>) session.getAttribute("user");
        Integer id = (Integer) map.get("eid");
        System.out.println(id);
        if(id==null){
            return (Integer) map.get("Aid");
        }else {
            return -1;
        }
    }

    /**
     * 住户结算
     * @param aid
     * @return
     */
    @RequestMapping(value = "zhuhujiaofei",method = RequestMethod.POST)
    @ResponseBody
    public Object zhuhujiaofei(String aid){
        return getDataService.zhuhujiaofei(aid);
    }
}
